package core.proto;

import java.awt.Color;
import java.awt.Font;

import javax.swing.Icon;
import javax.swing.JLabel;

public class IconData extends JLabel
{
  protected Icon   m_icon;
  protected Icon   m_closedIcon;
  protected Icon   m_expandedIcon;
  protected Object m_data;
  protected Object m_label;
  protected Color  m_backgroudColor;
  Icon grayIconClosed; 	
  Icon grayIconOpen;
  Icon grayIcon; 
  boolean isSearchHit;

  public IconData(Icon icon, Icon expandedIcon, Icon openGray, Icon closedGray, Color bg, Font font, Object data)
  { 
	  super(data.toString(),icon,LEFT);
	  m_icon = icon;
	  m_closedIcon = icon;
	  m_data = data;
	  m_expandedIcon = expandedIcon;
	  this.setBackground(bg);
	  this.setFont(font);
	  m_backgroudColor = Color.WHITE;
	  isSearchHit = true;
	  grayIconClosed = closedGray;
	  grayIconOpen = openGray;
	  grayIcon = closedGray;
  }

  public void useExpandedIcon() {
	  m_icon = m_expandedIcon;
	  grayIcon = grayIconOpen; 
  }
  
  public void setIsSearchHit(boolean b){
	  this.isSearchHit = b;
  }
  
  public boolean isSearchHit() {
	  return this.isSearchHit;
  }
  
  public Icon getIcon() 
  { 
     return m_icon;
  }

  public Icon getExpandedIcon() 
  { 
    Icon icon = m_expandedIcon!=null ? m_expandedIcon : m_icon;
    return icon;
  }

  public Object getObject() 
  { 
    return m_data;
  }

  public String toString() 
  { 
    return m_data.toString();
  }
}